#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>
#include <wait.h>

int a = 1;
int p[10] = {0};
pthread_mutex_t mutex;

int main() {
    pthread_mutex_init(&mutex, NULL);
    for (int i = 0; i < 10; i++) {
        p[i] = fork();
        if (p[i] == 0) {
            pthread_mutex_lock(&mutex);
            printf("the %d child\n", i);
            for (int j = 0; j < 10; j++)
                printf("%d ", p[j]);
            printf("\n");
            pthread_mutex_unlock(&mutex);
            exit(0);
        } else {
            // pthread_mutex_lock(&mutex);
            // for (int i = 0; i < 10; i++)
            //     printf("%d ", p[i]);
            // printf("\n");
            // pthread_mutex_unlock(&mutex);
        }
    }
    int status;
    wait(&status);
    return 0;
}